FROM python:3.12
WORKDIR /root/
ENV NLS_LANG="SIMPLIFIED CHINESE_CHINA.UTF8"

# 初始化环境
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
    echo "Asia/Shanghai" > /etc/timezone
RUN apt-get update -y && \
    apt-get install -y git vim wget unzip libaio1&& \
    apt-get install -y --no-install-recommends libgl1 libglib2.0-0 && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# 安装Oracle Instant Client 11.2
COPY instantclient_11_2/instantclient-*-linux*.zip /opt/oracle/
RUN mkdir -p /opt/oracle && \
    cd /opt/oracle && \
    unzip instantclient-basic-linux*.zip && \
    unzip instantclient-sdk-linux*.zip && \
    unzip instantclient-jdbc-linux*.zip && \
    unzip instantclient-odbc-linux*.zip && \
    unzip instantclient-sqlplus-linux*.zip && \
    rm -f *.zip && \
    mv instantclient_11_2 instantclient

# 配置Oracle环境变量
ENV ORACLE_HOME=/opt/oracle/instantclient
ENV LD_LIBRARY_PATH=$ORACLE_HOME:$LD_LIBRARY_PATH
ENV PATH=$ORACLE_HOME:$PATH

# 安装uv
RUN pip install --upgrade pip && \
    pip install uv

# 迁移pyproject.toml，安装依赖
COPY ./docwork-server/pyproject.toml /root/

# 使用uv初始化docker-server项目，安装依赖
RUN uv init docwork-server

RUN mv /root/pyproject.toml /root/docwork-server/

RUN cd /root/docwork-server/ && \
    uv sync

